﻿<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Cwjk_Project_Edit.aspx.vb" Inherits="PubProject.Cwjk_Project_Edit" %>
<%@ Register TagPrefix="cnt" Namespace="Mysoft.Map.Application.Controls" Assembly="Mysoft.Map.Application.Components" %>
<%@ Register TagPrefix="mnu" Namespace="Mysoft.Map.Application.Menus" Assembly="Mysoft.Map.Application.Components" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
	<HEAD>
		<title>适用范围设置</title>
		<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
		<meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
		<meta name="vs_defaultClientScript" content="JavaScript">
		<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
		<link rel="stylesheet" type="text/css" href="/_nav/menu.css">
		<link rel="stylesheet" type="text/css" href="/_common/styles/global.css">
		<link rel="stylesheet" type="text/css" href="/_grid/map_grid.css">
		<link rel="stylesheet" type="text/css" href="/_forms/styles/form.css">
		<link rel="stylesheet" type="text/css" href="/_nav/tabs.css">
		<link rel="stylesheet" type="text/css" href="/_nav/nav.css">
		<link rel="stylesheet" type="text/css" href="/_common/styles/select.css">
		<script language="javascript" src="/_controls/settings.aspx"></script>
		<script language="javascript" src="/_controls/setting.js"></script>
		<script language="javascript" src="/_controls/util/util.js"></script>
		<script language="javascript" src="/_controls/datetime/date.js"></script>
		<script language="javascript" src="/_controls/datetime/time.js"></script>
		<script language="javascript" src="/_controls/number/number.js"></script>
		<script language="javascript" src="/_controls/lookup/map_lookup.js"></script>
		<script language="javascript" src="/_controls/lookup/map_lookupDialogs.js"></script>
		<script language="javascript" src="/_nav/menu.js"></script>
		<script language="javascript" src="/_common/scripts/global.js"></script>
		<script language="javascript" src="/PubProject/js/Public.js"></script>
		<!-- workflow -->
		<script language="javascript" src="/MyWorkflow/workflow.js"></script>
		<script language="javascript" src="/slxt/js/Public.js"></script>
		<script language="javascript" src="/slxt/xsxc/XsXc_XsChg.js"></script>	
		<script language="javascript">
		//在线帮助文件
		    var _MyHelpfile = "/Cbgl/HELP/topics/财务人员/设置财务接口/设置账套.html";
		
	    // 初始化界面
		function window.onload()
		{
		    if (document.all("__mode") && document.all("__mode").value=="1")
            {
                document.all("saveandnew").style.display = "";
            }
            else
            {
                document.all("saveandnew").style.display = "none";
            }
            
		    var sCwztName = "";
		    
		    if (!document.getElementById("__CwztName") || document.getElementById("__CwztName").value=="")
			{
			    alert("请选择账套！");
			    return;
			}
			else
			{
			    sCwztName = document.getElementById("__CwztName").value;
			}
			
			appForm.appForm_CwztName.value = sCwztName;
			appForm.appForm_ProjName.readOnly = true;
			
			if( document.all("__Application") && document.all("__Application").value=="0101")
            {
                _MyHelpfile = "/Slxt/HELP/topics/财务管理/财务接口设置/账套设置.html";
            }
            
           	if( document.all("__mode") && (document.all("__mode").value=="1"||document.all("__mode").value=="2"))
            {	           
              appForm.appForm_ProjName.setReadOnly(true,false);
            }
        }
					
		//保存数据
		function Save()
		{   
		    appForm.Save();
		}		
		
		//保存并关闭
		function SaveAndNew()
		{
		     appForm.SaveAndNew();
		}
		
		//保存并关闭
		function SaveAndClose()
		{
		     appForm.SaveAndClose();
		}
		
		function CheckAppFromValue()
		{
		    if (appForm.CwztGUID.value=="")
			{
			    alert("请选择账套！");
			    return false;
			}
			
			if (appForm.ProjGUID.value=="")
			{
			    alert("请选择项目！");
			    return false;
			}

		    return true;
		}

		function oprBeforeSave()
		{
			var bCheckResult = CheckAppFromValue();
			
			if (bCheckResult)
			{
			    var sUserXml = "";
			    var sApplication = "0101";
		    
		        if (document.getElementById("__Application")!=null && document.getElementById("__Application")!=undefined && document.getElementById("__Application").value!="")
			    {
			        sApplication = document.getElementById("__Application").value;
			    }
			    
			    if (appForm.appForm_ProjGUID_Old.value!=appForm.ProjGUID.value)
			    {
			        sUserXml = "<myxml>";
	                sUserXml += "<dataxml entity=\"param\">";
	                sUserXml += "<BUGUID>" + appForm.BUGUID.value + "</BUGUID>";
	                sUserXml += "<ProjGUID>" + appForm.ProjGUID.value + "</ProjGUID>";
	                sUserXml += "<Application>" + sApplication + "</Application>";
	                sUserXml += "</dataxml>";
	                sUserXml += "</myxml>";
	            }
            		
	            appForm.userxml = sUserXml;
			}
			
			event.returnValue = bCheckResult;
		}
		
		function oprAfterSave()
		{
		  	var xmlDom = new ActiveXObject("Microsoft.XMLDOM")
		  	
	        try
	        {
		        xmlDom.loadXML(appForm.returnxml);
		        
		        if (xmlDom.documentElement.attributes.getNamedItem("result").value == "true")
	            {
	                //保存成功后的相关操作	                
	                appForm.appForm_ProjGUID_Old.value = appForm.ProjGUID.value;
	                
	                if (xmlDom.documentElement.attributes.getNamedItem("keyvalue").value!="")
	                {
	                    ParentGridRefresh(xmlDom.documentElement.attributes.getNamedItem("keyvalue").value);
	                }
	            }
	            else
	            {
	                //保存失败后的相关操作
	                //alert("保存失败，请与系统管理员联系！");
	                alert(xmlDom.documentElement.attributes.getNamedItem("errormessage").value);
	            }
	        }
	        catch(e)
	        {
		        alert("返回的xml格式错误，请与管理员联系！");
		        return;
	        }
		}
		
		//刷新父窗口页面
		function ParentGridRefresh(sProjectGUID)
		{
			//刷新主界面
			try
			{
				window.opener._appGrid_Query(sProjectGUID);		// 刷新网格 id="appGrid"
			}
			catch(e)
			{
			}
		}
		
		// 打开项目列表选择窗口
		function openAddProjWin()
		{
			var sTitle, sHeight, sWidth, sFile, sApplication = "";
			var sParm;
			
			if (!document.getElementById("__Application") || document.getElementById("__Application").value=="")
			{
			    return;
			}
			else
			{
			    sApplication = document.getElementById("__Application").value;
			}
			
			sTitle = "选择项目";
			sHeight = "450";
			sWidth = "360";
			
			sFile = "/PubProject/Cwjk/Cwjk_SelectProject.aspx";
			sParm ="Application=" + sApplication
		
			var sReturnValue = OpenModalWin(sTitle,sFile,sParm,sWidth,sHeight);

			if (sReturnValue!=undefined && sReturnValue!=null && sReturnValue != "")
			{
			    var arrReturnValue = sReturnValue.split('|');

			    if (arrReturnValue.length==2)
			    {
			        appForm.ProjGUID.value = arrReturnValue[0];
			        appForm.appForm_ProjName.value = arrReturnValue[1];
			    }
			}
		}
		
		</script>
	</HEAD>
	<body MS_POSITIONING="GridLayout">
		<table class="layout" cellSpacing="0" cellPadding="0">
			<COLGROUP>
				<col width="140"> <!-- 导航菜单：140px -->
				<col>
			</COLGROUP>
			<tr height="48" id="trzc">
				<td colSpan="2">
					<!-- 菜单 --><mnu:appformmenu id="appFormMenu" runat="server"></mnu:appformmenu></td>
			</tr>
			<tr>
				<td colSpan="2">
					<div class="area">
						<cnt:AppForm id="appForm" runat="server" processtype="xmlhttp" assembly="Mysoft.Map.Core" invokeclass="Mysoft.Map.Data.MyDB" invokefunction="SaveXml" onbeforesave="oprBeforeSave()" onaftersave="oprAfterSave()"></cnt:AppForm>
					</div>
				</td>
			</tr>
		</table>
		<form id="Form1" runat="server">
		</form>
	</body>
</HTML>
